#!/bin/bash
#定义变量
basepath=$(cd `dirname $0`;pwd)
source $basepath/conf/base.sh
if [ $# -ne 3 ];then
  usage
else
  exit 0
fi

[ $# -ne 4 ] && exit 11
#ssh连接密码
rootpasswd=$1
#各个机器的ip网段
netnum=$2
#各个机器的ip网络位
nethosts=$3
#为master节点主机部署ssh免密操作
name=$4

ping -c 3 www.baidu.com &>/dev/null
if [ $? -eq 0 ];then
  echo -e "\033[32m 百度连接正常 \033[0m"
  ssh_secret_free ${rootpasswd} ${netnum} ${nethosts}
else
  echo -e "\033[31m 百度连接失败 \033[0m"
  help
  exit 0
fi
#设置当前系统的基础环境准备
Environmental ${name}
registry_install(){
  loacl registry=$5
  local hosts=`ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|grep -v 172.17.0.1|awk '{print $2}'|tr -d "addr:"|head -1`
if [ ${registry} == docker ];then
    docker pull registry
    mkdir /opt/registry
    docker run -d -p 5000:5000 -v /opt/registry:/var/lib/registry registry
    docker tag tomcat ${hosts}:5000/tomcat
    docker push ${hosts}:5000/tomcat
else
    yum install -y docker-distribution
    systemctl enable --now docker-distribution
    curl "http://${hosts}:5000/v2/_catalog"
fi
}